package com.kevin.state.machine.enums;

import lombok.Getter;

/**
 * 状态枚举
 */
@Getter
public enum State {

    TRANSIT(1, "通行"),
    WARNING(2, "警示"),
    STOP(3, "停止");

    private final Integer id;
    private final String description;

    State(Integer id, String description) {
        this.id = id;
        this.description = description;
    }

    public static State valueOfId(Integer id) {
        for (State action : State.values()) {
            if (action.getId().equals(id)) {
                return action;
            }
        }
        throw new UnsupportedOperationException("Unsupported state !");
    }

}
